package com.nova.edc.service.energy.impl;

import org.springframework.beans.factory.annotation.Autowired;

import com.nova.edc.dao.energy.OPerateDao;
import com.nova.edc.model.energy.OPerate;
import com.nova.edc.service.energy.OPerateService;
import com.nova.frame.dao.buzz.query.Order;
import com.nova.frame.dao.buzz.query.Query;
import com.nova.frame.dao.pager.Page;
import com.nova.frame.dao.pager.PageList;
import com.nova.module.filter.query.Filter;
import com.seio.edc.util.DateUtil;

public class OPerateServiceImpl implements OPerateService {

	@Autowired
	private OPerateDao novaOPerateDao;

	@Override
	public PageList<OPerate> findPageList(OPerate oPerate, Page page,
			String sidx, String sord) {
		Query<OPerate> query = novaOPerateDao.query().addOrder(
				Order.custom(sord, sidx));
		Filter.addFilterCondition(query, oPerate);
		return query.pageList(page);
	}

	@Override
	public OPerate getById(Integer id) {
		return novaOPerateDao.getById(String.valueOf(id));
	}

	@Override
	public OPerate insert(OPerate oPerate) {
		oPerate.setAdddate(DateUtil.getCurDate());
		return novaOPerateDao.insert(oPerate);
	}

	@Override
	public int update(OPerate oPerate) {
		return novaOPerateDao.update(oPerate);
	}

	@Override
	public int deleteById(int id) {
		return novaOPerateDao.deleteById(String.valueOf(id));
	}
}
